/** 
 * Copyright (C), 2010-2012, TIETIAO Software Co.,Ltd. ALL RIGHTS RESERVED. 
 * File name:HomeAction.java
 * Version:1.0
 * Date:2011-12-6
 * Description: 后台主界面
 * author:zhijian.zhang
 */
package com.tietiao.action.bg;

import java.io.Writer;
import java.util.List;

import javax.annotation.Resource;

import net.sf.json.JSONArray;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.tietiao.common.action.BaseAction;
import com.tietiao.common.json.JsonControllerHelper;
import com.tietiao.dao.model.BgSysMenu;
import com.tietiao.service.bg.BgHomeService;

@Controller
@Scope("prototype")
public class HomeAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Resource(name = "bgHomeServiceImpl")
	private BgHomeService bgHomeService;

	/**
	 * 
	 * 功能：获取系统菜单的JSON数据
	 * 
	 * @author: zyxun
	 * @Date: 2011-10-12
	 * 
	 * @return 系统菜单的JSON数据
	 * @throws Exception
	 */
	public String getSysMenu() throws Exception {
		List<BgSysMenu> lstMenu = bgHomeService.getAllBgSysMenuList();
		// 将List数据转换成JSON数据
		JSONArray json = JSONArray.fromObject(lstMenu);
		Writer wt = this.response.getWriter();
		wt.write(json.toString());
		wt.flush();
		wt.close();
	   JsonControllerHelper.writeJsonToResponse(response,lstMenu);
		return null;
	}

	/**
	 * 
	 * 功能：进入主界面
	 * 
	 * @author: zhijian.zhang
	 * @Date: 2011-12-6
	 * 
	 * @return
	 */
	public String home() {
		return dispatcher("/jsp/bg/home/home.jsp");
	}
}
